Skip to content

net/http: prevent incorrect redirections when the path contains %2F%2F #39171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dunglas
Copy link
Contributor

@dunglas dunglas commented May 20, 2020

The current implementation of ServeMux incorrectly returns a 301 status
code when the path contains URL-encoded data, and especially URL-encoded
URLs.

Fixes #21955

Before this change, an URL such as "/r/https%3A%2F%2Fgoogle.com" where always triggering a 301, which is a bug preventing to pass escaped URLs as path parameters (common for redirection services for instance).

Unlike the patch proposed (and never merged) in #21955, this implementation relies on URL.RawPath which looks designed for this kind of use case, and is less intrusive.

The current implementation of ServeMux incorrectly returns a 301 status
code when the path contains URL-encoded data, and especially URL-encoded
URLs.

Fixes golang#21955
@googlebot googlebot added the cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change. label May 20, 2020
@gopherbot
Copy link
Contributor

This PR (HEAD: a7b1801) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/234657 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Damien Neil:

Patch Set 1: Code-Review-1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/234657.
After addressing review feedback, remember to publish your drafts!

@heschi heschi closed this Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

net/http: DefaultServeMux incorrectly redirect (301) to path if path includes %2F%2F
4 participants